package com.glamour.hlcity.module.dom.analysis.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.openide.util.lookup.ServiceProvider;

import com.glamour.hlcity.common.data.model.ClassifiedKey;
import com.glamour.hlcity.common.data.model.ClueNode;
import com.glamour.hlcity.common.data.model.TagAttribute;
import com.glamour.hlcity.common.data.model.TagNode;
import com.glamour.hlcity.common.enums.ClassifiedEnum;
import com.glamour.hlcity.common.model.Node;
import com.glamour.hlcity.common.util.ListUtil;
import com.glamour.hlcity.module.dom.analysis.Classified;
import com.glamour.hlcity.module.dom.analysis.ClueClassified;
/**
 * 
 * 节点名称相等，节点具有的属性个数和属性名称也是相同（这里的属性相同包含其顺序也是相同的）
 * @author zhaoxing.liuzx
 *
 */
@ServiceProvider(service = Classified.class)
public class TagAttributeClueClassified extends GeneralClueClassified {

	//文本节点
	private final static String TAG_ATTRIBUTE_NAME_TEXT="hlcity_html_text_tag_attribute";
	@Override
	public ClassifiedEnum getClassifiedEnum() {
		// "标签名称相同,属性个数和属性名称也相同"
		return ClassifiedEnum.ONLY_SAME_TAG_AND_ATTRIBUTE_NAME;
	}

	
	@Override
	public String classifiedKeyValue(Node node){
		if(Node.HTML_ELEMENT_TAG.equals(node.getNodeType())){
			StringBuffer sbuffer=new StringBuffer();
			sbuffer.append(node.getNodeName());
			if(node instanceof TagNode){
				TagNode tag=(TagNode)node;
				List<TagAttribute> attributeList=tag.getAttributeList();
				for(TagAttribute tagAttribute:attributeList){
					sbuffer.append("-").append(tagAttribute.getAttributeKey());
				}
			}
			return sbuffer.toString();
		}else{
			return TAG_ATTRIBUTE_NAME_TEXT;
		
		}

	}

}
